<!--
 * @Author: your name
 * @Date: 2022-04-12 09:53:42
 * @LastEditTime: 2022-04-12 10:14:49
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\给array对象添加一个本地的方法220412.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>删除重复条目</title>
</head>

<body>
  <script>
    // Array.prototype.delrepeat = function () {
    //   var arr = this;
    //   var _arr = new Array();
    //   for (var i in arr) {
    //     if (i == 'delreoeat') continue
    //     if (_arr.length == 0) _arr.push(arr[i]);
    //     for (var j = 0; j < _.length; j++) {
    //       if (arr[i] == _arr[j]) {
    //         break;
    //       }
    //       if (j > _arr.length - 2) {
    //         _arr.push(arr[i]);
    //       }
    //       return _arr
    //     }
    //   }
    // }
    // console.log(["1", "1", "2"].delrepeat())
    var arr = [1, 2, 3, 2, 3]
        Array.prototype.unique = function () {
            var brr = [];
            var obj = {};
            for (let i = 0; i < this.length; i++) {
                if (!obj[this[i]]) {
                    obj[this[i]] = true;
                    brr.push(this[i]);
                }
            }
            return brr;
        }
        console.log(arr.unique());//[1,2,3]

  </script>
</body>

</html>